package models.System.Systems;



import models.SystemModels.ShopDetails;
import models.SystemModels.folders;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * Created by Administrator on 2018-06-27.
 */
public class Systems implements models.interfaces.Systems {


    @Override
    public String ids(String titles) {
        try {
           if (titles.isEmpty()){
               SimpleDateFormat sdf =   new SimpleDateFormat("yyyyMMddHHmmss");
               StringBuffer sb = new StringBuffer();
               sb.append(sdf.format(new Date()));
               return sb.toString();
           }else{
               SimpleDateFormat sdf =  new SimpleDateFormat("yyyyMMddHHmmss");
               StringBuffer sb = new StringBuffer();
               sb.append(String.format("%s%s",titles,sdf.format(new Date())));
               return sb.toString();
           }
        }catch (Exception ex){
            SimpleDateFormat sdf =   new SimpleDateFormat("yyyyMMddHHmmss");
            StringBuffer sb = new StringBuffer();
            sb.append(sdf.format(new Date()));
            return sb.toString();
        }

    }

    @Override
    public String dates(Date date) {
        SimpleDateFormat sdf =  new SimpleDateFormat("yyyy年MM月dd日");
        StringBuffer sb = new StringBuffer();
        sb.append(sdf.format(date));
        return sb.toString();
    }

    @Override
    public String date(Date date) {

        SimpleDateFormat sdf =  new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒");
        StringBuffer sb = new StringBuffer();
        sb.append(sdf.format(date));
        return sb.toString();
    }

    @Override
    public String Folders(String Images) {
        List<folders> folder = folders.find("Images",Images).fetch();
        return folder.get(0).Id.toString();
    }

    @Override
    public String ShopDetailsId(String picture) {
        List<ShopDetails> Shop = ShopDetails.find("picture",picture).fetch();
        return  Shop.get(0).Id.toString();
    }
}
